phoneNmber = {'petert': '12154461321641', 'jack': '12154461321641'}


def addPhoneNumber(name, phoneN):
    phoneNmber[name] = phoneN
    print(f'新增成功{phoneNmber}')


def searchAll():
    print(f'所有联系人{phoneNmber}')


def delPhoneNum(name):
    phoneNmber.pop(name)
    print(f'剩余联系人{phoneNmber}')


def updPhoneNum(name, phoneN):
    phoneNmber[name] = phoneN
    print(f'修改后的联系人{phoneNmber}')


def searchPhone(name):
    print(f'电话号码{phoneNmber[name]}')


def main():
    print(
        '\t欢迎来到Python电话本\n\t 1 -> 添加联系人 \n\t 2 -> 查看所有联系人 \n\t 3 -> 删除联系人 \n\t 4 -> 修改联系人信息 \n\t 5 -> 查找联系人 \n\t 0 -> 退出')
    tag = -1
    while tag != 0:
        tag = int(input('请选择：'))
        if tag == 1:
            name = input("请输入联系人姓名：")
            phoneN = input("请输入电话号码：")
            addPhoneNumber(name, phoneN)
        elif tag == 2:
            searchAll()
        elif tag == 3:
            name = input("请输入删除联系人的姓名：")
            delPhoneNum(name)
        elif tag == 4:
            name = input("请输入修改联系人姓名：")
            phoneN = input("请输入新的电话号码：")
            updPhoneNum(name, phoneN)
        elif tag == 5:
            name = input("请输入搜索联系人的姓名：")
            searchPhone(name)
        elif tag == 0:
            print('已退出^__^')
        else:
            print('输入错误')


if __name__ == '__main__':
    main()
